package com.ymttest.database.sqlwapper;

import com.shop2cn.iapi.agentproducts.parameter.*;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.productmanager.parameter.BrandPo;
import com.ymatou.iapi.trading.operate.parameter.po.SubcatalogsPo;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.GrouponCatalogs;
import com.ymttest.database.model.GrouponProducts;
import com.ymttest.database.model.YmtProductsI;
import com.ymttest.database.model.Ymt_ProductDescConfigWord;
import com.ymttest.utils.MapUtil;

import org.apache.ibatis.annotations.Param;
import org.joda.time.DateTime;

import java.util.*;

/************************************************************************************
 * @File name : YmtProductsIWapper.java
 * @Author : 徐洁伟
 * @Date : 2016年6月28日
 * @Copyright : 洋码头
 * 商品合库 新库
 ************************************************************************************/
public class YmtProductsIWapper {
	SqlManager manage;

	public YmtProductsIWapper() {
		manage = new SqlManager("intpro");
	}

	//查询
	public List<YmtProductsI> selectProductByProductId(String sProductId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		Map m=new HashMap();
		m.put("sProductId", sProductId);
		List<YmtProductsI> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectProductByProductId",
						m);
		manage.commit();
		return sProductIdlist;
	}

    public List<CategoryDtoV2> selectCategoryByThirdCategoryId(int thirdCategoryId)
            throws InterruptedException {
        @SuppressWarnings("unchecked")
        List<CategoryDtoV2> sProductIdlist = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.YmtProductsIMapper.selectCategoryByThirdCategoryId",
                        thirdCategoryId);
        manage.commit();
        return sProductIdlist;
    }

	public List<Map> selectProductCategoryByCategoryId(int categoryId)
			throws InterruptedException {
		Map m = new HashMap();
		m.put("categoryId",categoryId);
		List<Map> list = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectProductCategoryByCategoryId",
						m);
		manage.commit();
		return list;
	}

	public List<Category> selectProductCategoryByCategoryIdV2(int categoryId)
			throws InterruptedException {
		Map m = new HashMap();
		m.put("categoryId",categoryId);
		List<Category> list = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectProductCategoryByCategoryIdV2",
						m);
		manage.commit();
		return list;
	}

	public List<CategoryDto> getSecondCategoryByUserId(int userId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<CategoryDto> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSecondCategoryByUserId",
						userId);
		manage.commit();
		return sProductIdlist;
	}


	//查询
	public List<Map> selectProductByProductIdforMap(String sProductId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectProductByProductIdforMap",
						sProductId);
		//	    manage.commit();
		return sProductIdlist;
	}

	//更新
	public int updateValidtimeByProductId(Date dvalidStart, Date dvalidEnd,
			String sProductId) throws InterruptedException {
		Map m = new HashMap();
		m.put("dvalidStart", dvalidStart);
		m.put("dvalidEnd", dvalidEnd);
		m.put("sProductId", sProductId);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateValidtimeByProductId",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	//更新
		/**
		 * #{AutoMarkup} where  productId = #{productId}
		 * @return
		 * @throws InterruptedException
		 */
		public int updateAgentProductAutoMarkup(String productId,boolean AutoMarkup) throws InterruptedException {
			if(productId==null||productId.length()<=0) {
				return 0;
			}
			Map m = new HashMap();
			m.put("AutoMarkup", AutoMarkup);
			m.put("productId", productId);
			int i = manage
					.update("com.ymttest.database.mapping.YmtProductsIMapper.updateAgentProductAutoMarkup",
							m);
			manage.commit();
			// manage.close();
			return i;
		}

	public int updateCatalogTypeByProductId(String productId, int catalogType) {
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateCatalogTypeByProductId",
						MapUtil.hashMap("sProductId", productId,
								"iCatalogType", catalogType));
		manage.commit();
		return i;
	}

	//更新YMT_SellerLoginLimitAutoOnShevel
	public int updateSellerLoginByUserId(Date dStartTime, Date dEndTime,
			int userId) throws InterruptedException {
		Map m = new HashMap();
		m.put("dStartTime", dStartTime);
		m.put("dEndTime", dEndTime);
		m.put("userId", userId);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateSellerLoginByUserId",
						m);
		manage.commit();
		// manage.close();
		return i;
	}

	public int updateIsNewByUserId(int sellerId, boolean isNew) {
		Map m = new HashMap();
		m.put("iUserId", sellerId);
		m.put("isNew", isNew);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateIsNewByUserId",
						m);
		manage.commit();
		// manage.close();
		return i;
	}

	
	public int updateCheckStatus(String productId, int checkStatus) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("CheckStatus", checkStatus);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateCheckStatus",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	
	
	public int updateCategoryId(String productId, int categoryId) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("CategoryId", categoryId);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateCategoryId",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	
	public List<Map> getProductTemplate(int productTemplateId) {
		Map m = new HashMap();
		m.put("Id", productTemplateId);
		List<Map> list = manage
				.getSelectResults("com.ymttest.database.mapping.YmtProductsIMapper.getProductTemplate",
						m);
		//manage.commit();
		return list;
	}
	
	/**
	 * 用于强制商品失效
	 * @param productId
	 * @param iaction
	 * @return
	 */
	public int updateProductAction(String productId, int iaction) {
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("iaction", iaction);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateProductAction",
						m);
		manage.commit();
		return i;
	}

	public int updateProductPackageDeliveryType(String productId, int packageDeliveryType) {
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("packageDeliveryType", packageDeliveryType);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateProductPackageDeliveryType",
						m);
		manage.commit();
		return i;
	}

	public int updateCatalogStatus(String productId, int catalogStatus) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("CatalogStatus", catalogStatus);
		int i = manage																					
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateCatalogStatus",
						m);
		manage.commit();
		// manage.close();
		return i;
	}

	public int updateAgentProductInfoProgress(String productId, int infoProgress) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("infoProgress", infoProgress);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateAgentProductInfoProgress",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	
	public int updatePspStatus(String productId, int pspStatus) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("PspStatus", pspStatus);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updatePspStatus",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	public List<Map> selectPspStatus(String productId, int sellerId) {
		Map m = new HashMap();
		m.put("ProductId", productId);
		m.put("SellerId", sellerId);
		List<Map> list = manage.getSelectResults
				("com.ymttest.database.mapping.YmtProductsIMapper.selectPspStatus",
						m);
		manage.commit();
		// manage.close();
		return list;
	}
	
	public int updateProductsInLiveTop(String productId, int sellerId,Integer itop) {
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("sellerId", sellerId);
		m.put("itop",itop);
		int i = manage
				.update("com.ymttest.database.mapping.YmtProductsIMapper.updateProductsInLiveTop",
						m);
		manage.commit();
		// manage.close();
		return i;
	}
	
	
	//查询
	public List<Map> selectSubscribeRecord(int iUserId, String sSKU)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		Map m = new HashMap();
		m.put("iUserId", iUserId);
		m.put("sSKU", sSKU);
		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectSubscribeRecord",
						m);
		//	    manage.commit();
		return sProductIdlist;
	}

	public List<BrandPo> getCommonBrands(int action, List<Integer> brandIds) throws InterruptedException {
		@SuppressWarnings("unchecked")
		Map m = new HashMap();
		m.put("action", action);
		m.put("brandIds", brandIds);
		List<BrandPo> brands = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getCommonBrands",
						m);
		return brands;
	}
	//查询商品描述
	public List<Map> selectDescConfigByProductId(String sProductId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectDescConfigByProductId",
						sProductId);
		//	    manage.commit();
		return sProductIdlist;
	}
	
	public List<Map> selectDescPicConfigByProductId(String sProductId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.selectDescPicConfigByProductId",
						sProductId);
		//	    manage.commit();
		return sProductIdlist;
	}

	public List<Map> getSellerProductDetailList(String productId, int sellerId,
			int curPage, int pageSize) throws InterruptedException {

		Map m = new HashMap();
		m.put("productId", productId);
		m.put("sellerId", sellerId);
		m.put("curPage", curPage);
		m.put("pageSize", pageSize);

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSellerProductDetailList",
						m);
		//	    manage.commit();
		return sProductIdlist;
	}

	public List<Map> getSellerProductDetailList_product(String productId)
			throws InterruptedException {

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSellerProductDetailList_product",
						productId);
		return sProductIdlist;
	}
	
	public List<Map> getCategorys(int userid)
			throws InterruptedException {

		List<Map> sCatagorys = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getCategorys",
						userid);
		return sCatagorys;
	}
	
	public List<Map> getBrands(int userid)
			throws InterruptedException {

		List<Map> sBrands = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getBrands",
						userid);
		return sBrands;
	}
	
	public List<Map> getFullProductCategoriesByUserId(int userid)
			throws InterruptedException {

		List<Map> sProductCategories = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getFullProductCategoriesByUserId",
						userid);
		return sProductCategories;
	}

	public List<Map> getSellerProductDetailList_Catalogs(String productId,
			Integer sellerId) throws InterruptedException {
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("sellerId", sellerId);

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSellerProductDetailList_Catalogs",
						m);
		return sProductIdlist;
	}

	public List<Map> getSellerProductDetailList_CatalogProperty(String productId)
			throws InterruptedException {

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSellerProductDetailList_CatalogProperty",
						productId);
		return sProductIdlist;
	}

	public List<Map> getSellerProductDetailList_ProductPicture(String productId)
			throws InterruptedException {

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSellerProductDetailList_ProductPicture",
						productId);
		return sProductIdlist;
	}

	public List<Map> getProductDeliveryTemplateByProdId(String productId)
			throws InterruptedException {

		List<Map> sProductIdlist = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getProductDeliveryTemplateByProdId",
						productId);
		return sProductIdlist;
	}

	public List<String> GetFBXCatalogsByUserId(int userId)
			throws InterruptedException {

		manage.commit();
		Map m = new HashMap();
		m.put("userId", userId);
		List<String> list = manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.GetFBXCatalogsByUserId",
				m);
		return list;
	}

	/**
	 * ymt_subcatalogs 随机返回前100条中的一条组合商品
	 * @return
	 * @throws InterruptedException
	 */
	public SubcatalogsPo getSubcatalogs() throws InterruptedException {

		List<SubcatalogsPo> subcatalogsPoList = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getSubcatalogs",
						null);

		return subcatalogsPoList.get(new Random().nextInt(subcatalogsPoList
				.size() - 1));

	}
	public Integer getiTotalStock(String pid) throws InterruptedException {
		manage.commit();
		Map m = (Map) manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getiTotalStock",
						pid).get(0);
		Integer iTotalStock=m==null?0:(int) m.get("iTotalStock");
		return iTotalStock;

	}
	
	public List<Map> getBatchUpdatePspProductStatus(Integer sellerId) throws InterruptedException {
		manage.commit();
		Map m = new HashMap();
		m.put("sellerId", sellerId);
		List<Map> list = manage.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getBatchUpdatePspProductStatus",
						m);
		return list;

	}
	
	public List<Map> getBatchUpdatePspProductStatus2(Integer sellerId) throws InterruptedException {
		manage.commit();
		Map m = new HashMap();
		m.put("sellerId", sellerId);
		List<Map> list = manage.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getBatchUpdatePspProductStatus2",
						m);
		return list;

	}
	
	public Short getPspStatus(String productId) throws InterruptedException {
		manage.commit();
		Map m = (Map) manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getPspStatus",
						productId).get(0);
		Short pspStatus=(Short)m.get("pspStatus");
		return pspStatus;
	}
	
	public Integer getProductsInLiveTop(String productId,Integer sellerId) throws InterruptedException {
		manage.commit();
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("sellerId", sellerId);
		List<Map> list = manage.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getProductsInLiveTop",
						m);
		Integer top=(Integer)list.get(0).get("itop");
		return top;
	}
	
	public Integer getProductSeatNum(String productId,Integer sellerId) throws InterruptedException {
		manage.commit();
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("sellerId", sellerId);
		List<Map> list = manage.getSelectResults(
						"com.ymttest.database.mapping.YmtProductsIMapper.getProductSeatNum",
						m);
		Integer c=(Integer)list.get(0).get("c");
		return c;
	}
	
	public Ymt_ProductDescConfigWord getProductDescConfigWord(String productId) throws InterruptedException {
	    @SuppressWarnings("unchecked")
	    Ymt_ProductDescConfigWord Ymt_ProductDescConfigWord=new Ymt_ProductDescConfigWord();
	    List<Ymt_ProductDescConfigWord>  Ymt_ProductDescConfigWordlst = manage.getSelectResults(
	            "com.ymttest.database.mapping.YmtProductsIMapper.getProductDescConfigWord", productId);
	    if(Ymt_ProductDescConfigWordlst.size()>0)
	    	Ymt_ProductDescConfigWord=Ymt_ProductDescConfigWordlst.get(0);
	    
	    return Ymt_ProductDescConfigWord;
	}

	/**
	 *
	 * 查询Ymt_CommisionLogs
	 * @param args
	 * @throws Exception
	 */
	public List<Map> selectCommissionLogByProductId(String productId){
		manage.commit();
		Map m = new HashMap();
		m.put("productId", productId);
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectCommissionLogByProductId",
				m);
		return list;
	}
	/**
	 * @param map  GrouponProducts.ProductId=pid and GrouponProducts.Version=version and GrouponProducts.Status=status
	 * @return
	 */
	public List<GrouponProducts> selectGrouponProducts(String pid,Integer version,Integer status){
		manage.commit();
		Map m = new HashMap();
		m.put("pid", pid);
		m.put("version", version);
		m.put("status", status);
		List<GrouponProducts> list = manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectGrouponProducts",
				m);
		manage.commit();
		return list;
	}

	public List<Map> selectBusinessCredentialInfo(String productId,String actionType,Long version){
		manage.commit();
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("actionType", actionType);
		m.put("ExtParam",version);
		List<Map> list = manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectBusinessCredentialInfo",
				m);
		manage.commit();
		return list;
	}
	/**
	 * @param map CatalogId=cid Version=version
	 * @return
	 */
	public List<GrouponCatalogs> selectGrouponCatalogs(String cid,Integer version){
		manage.commit();
		Map m = new HashMap();
		m.put("cid", cid);
		m.put("version", version);
		List<GrouponCatalogs> list = manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectGrouponCatalogs",
				m);
		return list;
	}
	
	
	/**
	 * @param map productId=productId Version=version
	 * status=0：正常 status=1：停止拼团
	 * @return
	 */
	public int updateStatusGrouponProducts(String productId,Long version,Integer status,String startTime,String endTime){

		Map m = new HashMap();
		m.put("productId", productId);
		m.put("version", version);
		m.put("status", status);
		m.put("startTime", startTime);
		m.put("endTime", endTime);
		int result= manage.update(
				"com.ymttest.database.mapping.YmtProductsIMapper.updateStatusGrouponProducts",
				m);
		manage.commit();
		return result;
	}

	public int insertAgentProduct(AgentProductPo po){
		Integer i=manage.insert(
				"com.ymttest.database.mapping.YmtProductsIMapper.insertAgentProduct", po);
		manage.commit();
		return i;
	}

	public AgentProductPo selectAgentProductByProductId(String productId){
		Map m = new HashMap();
		m.put("productId", productId);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByProductId", m);
		manage.commit();
		return list.get(0);
	}

	public List<AgentProductPo> selectAgentProductByRootProductId(String productId){
		Map m = new HashMap();
		m.put("productId", productId);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByRootProductId", m);
		manage.commit();
		return list;
	}

	public List<AgentProductPo> selectAgentProductByUserId(int userId,int action){
		Map m = new HashMap();
		m.put("userId", userId);
		m.put("action", action);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByUserId", m);
		manage.commit();
		return list;
	}

	public List<AgentProductPo> selectAgentProductByParentProductId(String parentProductId){
		Map m = new HashMap();
		m.put("parentProductId", parentProductId);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByParentProductId", m);
		manage.commit();
		return list;
	}


	/**
	 * 根据上级商品id和自己的商户id查自己的商品id
	 * @param parentProductId
	 * @param userid
	 * @return
	 */
	public List<AgentProductPo> selectAgentProductByParentProductIdAndUserId(String parentProductId,Integer userid){
		Map m = new HashMap();
		m.put("parentProductId", parentProductId);
		m.put("userid", userid);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByParentProductIdAndUserId", m);
		manage.commit();
		return list;
	}
	
	public List<AgentProductPo> selectAgentProductByProductIdAndUserId(String productId,int userid){
		Map m = new HashMap();
		m.put("productId", productId);
		m.put("userid", userid);
		List<AgentProductPo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductByProductIdAndUserId", m);
		manage.commit();
		return list;
	}

	public List<AgentPricePo> selectAgentPriceByCatalogId(String catalogId,int agnetTypeId){
		Map m = new HashMap();
		m.put("catalogId", catalogId);
		m.put("agnetTypeId", agnetTypeId);
		List<AgentPricePo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentPriceByCatalogId", m);
		manage.commit();
		return list;
	}

	public List<PriceModel> selectAgentProductPrice(String catalogId){
		Map m = new HashMap();
		m.put("catalogId", catalogId);
		List<PriceModel> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentProductPrice", m);
		manage.commit();
		return list;
	}

	public List<AgentPricePo> selectAgentPriceById(String catalogId){
		Map m = new HashMap();
		m.put("catalogId", catalogId);
		List<AgentPricePo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentPriceById", m);
		manage.commit();
		return list;
	}

	public List<AgentPricePo> selectAgentPriceByProductIdAndUserId(String producId,int userId){
		Map m = new HashMap();
		m.put("producId", producId);
		m.put("userId", userId);
		List<AgentPricePo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentPriceByCatalogIdAndUserId", m);
		manage.commit();
		return list;
	}

	public List<AgentPricePo> selectAgentPriceByCatalogIdAndAgentType(String catalogId,int agentTypeId){
		Map m = new HashMap();
		m.put("catalogId", catalogId);
		m.put("agentTypeId", agentTypeId);
		List<AgentPricePo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentPriceByCatalogIdAndAgentType", m);
		manage.commit();
		return list;
	}

	public List<AgentPricePo> selectAgentPriceByAgentType(int agentTypeId){
		Map m = new HashMap();
		m.put("agentTypeId", agentTypeId);
		List<AgentPricePo> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentPriceByAgentType", m);
		manage.commit();
		return list;
	}

	public List<Map> selectAgentWxCodePicByProductId(String productId){
		Map m = new HashMap();
		m.put("productId", productId);
		List<Map> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectAgentWxCodePicByProductId", m);
		manage.commit();
		return list;
	}

	public List<Map> selectProductPictures(String productId){
		Map m = new HashMap();
		m.put("productId", productId);
		List<Map> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectProductPictures", m);
		manage.commit();
		return list;
	}

	public List<Map> selectUserCatalogProperty(String propertyName,String propertyValue){
		Map m = new HashMap();
		m.put("propertyName", propertyName);
		m.put("propertyValue",propertyValue);
		List<Map> list=manage.getSelectResults(
				"com.ymttest.database.mapping.YmtProductsIMapper.selectUserCatalogProperty", m);
		manage.commit();
		return list;
	}


    public List<Map> selectUserCatalogPropertyByUserId(int sellerId){
        Map m = new HashMap();
        m.put("sellerId", sellerId);
        List<Map> list=manage.getSelectResults(
                "com.ymttest.database.mapping.YmtProductsIMapper.selectUserCatalogPropertyByUserId", m);
        manage.commit();
        return list;
    }

    /**
     * 查询spu商品
     * @param sellerId
     * @return
     */
    public List<Map> GetSpuProductBySellerId(int sellerId,int SpuId){
        Map m = new HashMap();
        m.put("sellerId", sellerId);
        m.put("SpuId", SpuId);
        List<Map> list=manage.getSelectResults(
                "com.ymttest.database.mapping.YmtProductsIMapper.selectSpuProducts", m);
        manage.commit();
        return list;
    }
    
    
    /**
     * 删除老spu商品
     * @param sellerId
     * @return
     */
    public void DeleteSpuProductByProductId(String productId){
        Map m = new HashMap();
        m.put("productId", productId);
        manage.delete("com.ymttest.database.mapping.YmtProductsIMapper.DeleteProductsByProductId", m);
        manage.delete("com.ymttest.database.mapping.YmtProductsIMapper.DeleteCataLogsByProductId", m);
        manage.commit();
    }
    

	public static void main(String args[]) throws Exception {
		System.out.println(new YmtProductsIWapper().selectAgentProductByProductId("p2360407"));
	}

}
